#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //QPushButton* mybutton = new QPushButton(this);
    //mybutton -> setText("disabled mybutton");

    //禁用这个按钮
    //mybutton -> setEnabled(false);

    QRect rect1 = this->geometry();
    QRect rect2 = this->frameGeometry();

    qDebug() << rect1;
    qDebug() << rect2;
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_target_clicked()
{
    QRect rect = ui->target -> geometry();
    qDebug() << rect;
    //rect.setY(rect.y() + 5);



    this->close();

}

void Widget::on_left_clicked()
{
    QRect rect = ui->target -> geometry();
    qDebug() << rect;
    //这种写法会改变高和宽
//    rect.setX(rect.x() - 5);
//    ui->target->setGeometry(rect);

    ui->target->setGeometry(rect.x()-5,rect.y(),rect.width(), rect.height());
}

void Widget::on_up_clicked()
{
    QRect rect = ui->target -> geometry();
    qDebug() << rect;
//    rect.setY(rect.y() - 5);
//    ui->target->setGeometry(rect);

    ui->target->setGeometry(rect.x(),rect.y()-5,rect.width(), rect.height());
}

void Widget::on_down_clicked()
{
    QRect rect = ui->target -> geometry();
    qDebug() << rect;
//    rect.setY(rect.y() + 5);
//    ui->target->setGeometry(rect);

    ui->target->setGeometry(rect.x(), rect.y()+5, rect.width(), rect.height());
}

void Widget::on_right_clicked()
{
    QRect rect = ui->target -> geometry();
    qDebug() << rect;
//    rect.setX(rect.x() + 5);
//    ui->target->setGeometry(rect);

    ui->target->setGeometry(rect.x()+5, rect.y(), rect.width(), rect.height());
}

void Widget::on_agree_clicked()
{
    ui->label->setText("菜就多练");


}

void Widget::on_disagree_clicked()
{
    //转为press
}

void Widget::on_disagree_pressed()
{
    srand(time(0));

    int width = this->geometry().width();
    int height = this->geometry().height();

    int x = rand() % width;
    int y = rand() % height;

    ui->disagree->move(x,y);
}

void Widget::on_out_clicked()
{
    //不带标题栏
    QRect rect1 = this->geometry();

    //带标题栏
    QRect rect2 = this->frameGeometry();

    qDebug() << rect1;
    qDebug() << rect2;
}
